package com.myway.dto.ticket;

import com.myway.dto.order.DTOPaxSegment;
import com.myway.dto.payment.DTOPayment;

import java.util.ArrayList;
import java.util.List;

/**
 * @类名称：DTOFltRefundPaxSeg 
 * @类描述：申请退票航段 
 * @创建时间：2015年11月11日 下午7:57:11 
 * @author Jiang.Yida
 * @version V1.0
 */
public class DTOFltRefundPaxSeg implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6918625642433369645L;

	private Long id;

	private Long refundId;
	private DTOPaxSegment paxSegment;				// 取消的航段
	private double fareRefundAmount = 0;			//fareRefundAmount: 票价退款 
	private double airportTaxRefundAmount = 0;		//airportTaxRefundAmount: 机建税退款 
	private double fuelSurchargeRefundAmount = 0;	//fuelSurchargeRefundAmount: 燃油附加费退款
	private double otherTaxesRefundAmount = 0;		//otherTaxesRefundAmount: 其他税退款
	private double actualRefundAmount = 0;			//actualRefundAmount: 实际退款 
	private double fareRefundRate = 0;				//fareRefundRate: 票价退款税率 
	private double processFeeRate = 0;				//processFeeRate: 手续费税率 
	private double processFee=0;					//手续费
	private double sxyprocessFeeRate = 0;			//随心游的手续费费率
	private double sxyprocessFee = 0;				//随心游的手续费
	private String remark;							//备注字段票价退款金额计算,预计退税规则进行设置。
    private double baseAmountForFee=0;				//随心游产品手续费基础票价
	private double applyAmount = 0;
	private int refundPoint = 0;					//是否退还积分
	private double serviceOrderAmount = 0;			//辅营产品费用
	private double amsRefundPoint =0;				//实际退积分金额
	private double mealFee =0;						//机上餐食
	private double luggageFee =0;					//逾重行李
	private double itinerary =0;					//行程单
    private double realRebate = 0;					//真实折扣：特价产品/基础运价 用于计算退票费率
    private double applyAmsRefundPoint =0;			//申请退积分金额
    
    private Long changeId;//改期升舱id
	private Long extBuyId;//补购id
	private String   refundStatus;//退款状态
	private String payMode;//退款方式(OFFLINE线下/手动、ONLINE线上/自动)
	private String refundFormId;//退票单ID(IBE)
	private String paymentNo;//支付流水号
	
	private List<DTOPayment> payments=new ArrayList<DTOPayment>();
    
	public double getMealFee() {
		return mealFee;
	}

	public void setMealFee(double mealFee) {
		this.mealFee = mealFee;
	}

	public double getLuggageFee() {
		return luggageFee;
	}

	public void setLuggageFee(double luggageFee) {
		this.luggageFee = luggageFee;
	}


	public double getItinerary() {
		return itinerary;
	}

	public void setItinerary(double itinerary) {
		this.itinerary = itinerary;
	}

	public DTOFltRefundPaxSeg() {

	}

	@Override
	protected void finalize() throws Throwable {
		super.finalize();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getRefundId() {
		return refundId;
	}

	public void setRefundId(Long cancelId) {
		this.refundId = cancelId;
	}

	public DTOPaxSegment getPaxSegment() {
		return paxSegment;
	}

	public void setPaxSegment(DTOPaxSegment paxSegment) {
		this.paxSegment = paxSegment;
	}

	public double getFareRefundAmount() {
		return fareRefundAmount;
	}

	public void setFareRefundAmount(double fareRefundAmount) {
		this.fareRefundAmount = fareRefundAmount;
	}

	public double getAirportTaxRefundAmount() {
		return airportTaxRefundAmount;
	}

	public void setAirportTaxRefundAmount(double airportTaxRefundAmount) {
		this.airportTaxRefundAmount = airportTaxRefundAmount;
	}

	public double getFuelSurchargeRefundAmount() {
		return fuelSurchargeRefundAmount;
	}

	public void setFuelSurchargeRefundAmount(double fuelSurchargeRefundAmount) {
		this.fuelSurchargeRefundAmount = fuelSurchargeRefundAmount;
	}

	public double getOtherTaxesRefundAmount() {
		return otherTaxesRefundAmount;
	}

	public void setOtherTaxesRefundAmount(double otherTaxesRefundAmount) {
		this.otherTaxesRefundAmount = otherTaxesRefundAmount;
	}

	public double getRefundAmount() 
	{
		double totalTax=0.0;
//		if(paxSegment.getPaxsegTaxList()!=null)
//		{
//			for(DTOPaxsegTax tax:paxSegment.getPaxsegTaxList())
//			{
//				totalTax =totalTax+tax.getFare();
//			}
//		}
//		return fareRefundAmount + airportTaxRefundAmount + fuelSurchargeRefundAmount + otherTaxesRefundAmount+serviceOrderAmount+totalTax;
		return fareRefundAmount;
	}
	
	public double getTotalTax() 
	{
		double totalTax=0.0;
//		if(paxSegment.getPaxsegTaxList()!=null)
//		{
//			for(DTOPaxsegTax tax:paxSegment.getPaxsegTaxList())
//			{
//				totalTax =totalTax+tax.getFare();
//			}
//		}
		return totalTax;

	}
	

	public double getActualRefundAmount() {
		return actualRefundAmount;
	}

	public void setActualRefundAmount(double actualRefundAmount) {
		this.actualRefundAmount = actualRefundAmount;
	}

	/**
	 * @return the applyAmount
	 */
	public double getApplyAmount() {
		/*//头等舱退票手续费为零,申请全退
		if(paxSegment.getCabinClass().equals("F")){	
			List<DTOInsurance> insuranList = paxSegment.getInsuranceList();
			double insuranceFare=0;
			if(insuranList!=null&&insuranList.size()>0)
			{
				for(DTOInsurance dtoInsurance:insuranList)
				{
					if((!dtoInsurance.getStatus().equals( InsuranceStatus.XX.toString()))&&(!dtoInsurance.getStatus().equals( InsuranceStatus.OH.toString()))
							&&(!dtoInsurance.getStatus().equals( InsuranceStatus.OF.toString())))								
					{
						insuranceFare+=dtoInsurance.getAmount();
					}
				}
			}
			this.applyAmount=paxSegment.getNetFare()+paxSegment.getAirportTax()+paxSegment.getFuelTax()+insuranceFare;
		}*/
		return applyAmount;
	}

	/**
	 * @return the refundPoint
	 */
	public int getRefundPoint()
	{
		return refundPoint;
	}

	/**
	 * @param refundPoint the refundPoint to set
	 */
	public void setRefundPoint(int refundPoint)
	{
		this.refundPoint = refundPoint;
	}

	/**
	 * @param applyAmount
	 *            the applyAmount to set
	 */
	public void setApplyAmount(double applyAmount) {
		this.applyAmount = applyAmount;
	}

	public double getFareRefundRate() {
		return fareRefundRate;
	}

	public void setFareRefundRate(double fareRefundRate) {
		this.fareRefundRate = fareRefundRate;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public double getProcessFeeRate() {
		return processFeeRate;
//		double result=1;
//		double processFee=this.getProcessFee();
//		if("GS".equalsIgnoreCase(paxSegment.getAirlineCode())&&paxSegment.getPointPrice()>0){
//			//手续费小于实际售价，大于则按照100%计算  处理价格<(获得净票价+折扣价)
//			if(processFee<(paxSegment.getNetFare()+paxSegment.getPointPrice())){
//				//处理价/市场价格
//				result=processFee/paxSegment.getMarketFare();
//			}
//		}else{
//			//手续费小于实际售价，大于则按照100%计算
//			if(processFee<paxSegment.getNetFare()){
//				result=processFee/paxSegment.getMarketFare();
//			}
//		}
//		return result*100;
	}

	public void setProcessFeeRate(double processFeeRate) {
		this.processFeeRate = processFeeRate;
	}

	/**
	 * @return the processFee
	 */
	public double getProcessFee() {
		return processFee;
//		double result=0;
//		double insuranceFare=0; //保险套餐
//		double totalTax=0;//总税收
//		double refundAmount=actualRefundAmount; 	//退票金额
//		double serviceAmount = serviceOrderAmount;	//服务金额
//		if(actualRefundAmount==0){
//			refundAmount=this.applyAmount;		
//		}
//		
//		//DTOPaxsegTax 旅客航段税费
//		if(paxSegment.getPaxsegTaxList()!=null&&paxSegment.getPaxsegTaxList().size()>0){
//			for(DTOPaxsegTax tax:paxSegment.getPaxsegTaxList()){
//				totalTax=totalTax+tax.getFare();
//			}
//		}
//
//		if("GS".equalsIgnoreCase(paxSegment.getAirlineCode())&&paxSegment.getPointPrice()>0){
//			//净票价+价格点+机场税+燃油税+总税收+保险套餐+服务金额-（退票金额+ams退款点）
//			result=(paxSegment.getNetFare()+paxSegment.getPointPrice()+paxSegment.getAirportTax()+paxSegment.getFuelTax()+totalTax+insuranceFare+serviceAmount -(refundAmount+this.amsRefundPoint));
//			if(actualRefundAmount==0 && amsRefundPoint>0 && result < 0 ){
//				result =0;
//			}
//			if(result>=(paxSegment.getNetFare()+paxSegment.getPointPrice())){
//				//市场票价
//				result = paxSegment.getMarketFare();
//			}
//		}else{
//			result=(paxSegment.getNetFare()+paxSegment.getAirportTax()+paxSegment.getFuelTax()+totalTax+insuranceFare+serviceAmount -refundAmount);
//			if(result>=paxSegment.getNetFare()){
//				result = paxSegment.getMarketFare();
//			}
//		}
//		return result;
	}

	/**
	 * @param processFee the processFee to set
	 */
	public void setProcessFee(double processFee) {
		this.processFee = processFee;
	}

	public double getServiceOrderAmount() {
		return serviceOrderAmount;
	}

	public void setServiceOrderAmount(double serviceOrderAmount) {
		this.serviceOrderAmount = serviceOrderAmount;
	}

	public double getAmsRefundPoint() {
		return amsRefundPoint;
	}

	public void setAmsRefundPoint(double amsRefundPoint) {
		this.amsRefundPoint = amsRefundPoint;
	}

	public double getBaseAmountForFee() {
		return baseAmountForFee;
	}

	public void setBaseAmountForFee(double baseAmountForFee) {
		this.baseAmountForFee = baseAmountForFee;
	}

	public double getSxyprocessFeeRate() {
		return sxyprocessFeeRate;
	}

	public void setSxyprocessFeeRate(double sxyprocessFeeRate) {
		this.sxyprocessFeeRate = sxyprocessFeeRate;
	}

	public double getSxyprocessFee() {
		return sxyprocessFee;
	}

	public void setSxyprocessFee(double sxyprocessFee) {
		this.sxyprocessFee = sxyprocessFee;
	}

    public double getRealRebate() {
        try {
//            this.realRebate = this.getPaxSegment().getNetFare()/this.getPaxSegment().getBaseFare();
        }catch (Exception e){

            this.realRebate = 0;
        }
        return realRebate;
    }

    public void setRealRebate(double realRebate) {
        this.realRebate = realRebate;
    }

	public double getApplyAmsRefundPoint() {
		return applyAmsRefundPoint;
	}

	public void setApplyAmsRefundPoint(double applyAmsRefundPoint) {
		this.applyAmsRefundPoint = applyAmsRefundPoint;
	}

	public Long getChangeId() {
		return changeId;
	}

	public void setChangeId(Long changeId) {
		this.changeId = changeId;
	}

	public Long getExtBuyId() {
		return extBuyId;
	}

	public void setExtBuyId(Long extBuyId) {
		this.extBuyId = extBuyId;
	}

	public String getRefundStatus() {
		return refundStatus;
	}

	public void setRefundStatus(String refundStatus) {
		this.refundStatus = refundStatus;
	}

	public String getPayMode() {
		return payMode;
	}

	public void setPayMode(String payMode) {
		this.payMode = payMode;
	}

	public List<DTOPayment> getPayments() {
		return payments;
	}

	public void setPayments(List<DTOPayment> payments) {
		this.payments = payments;
	}

	public String getPaymentNo() {
		return paymentNo;
	}

	public void setPaymentNo(String paymentNo) {
		this.paymentNo = paymentNo;
	}
}